from menu . gui import menu_gui

class frame_fake :
    def __init__ ( self , master ) :
        self . _master = master
        self . _packed = False
        self . _destroyed = False

class mediator_fake :
    def __init__ ( self ) :
        self . _menu_gui = None
        self . _application_window = None
        self . _create_new_table_in_frame_history = [ ]
        self . _frames = [ ]
    def application_window_request ( self ) :
        self . _menu_gui . application_window_reply ( self . _application_window )
    def create_new_table_in_frame ( self , frame ) :
        self . _create_new_table_in_frame_history += [ frame ]
    def gui_create_frame_request ( self , master ) :
        frame = frame_fake ( master )
        self . _frames += [ frame ]
        self . _menu_gui . gui_create_frame_reply ( frame )
    def gui_destroy_frame ( self , frame ) :
        frame . _destroyed = True
    def gui_pack ( self , widget , padx = None , pady = None , side = None , fill = None ) :
        widget . _packed = True
    def gui_side_top ( self ) :
        pass
    def gui_fill_x ( self ) :
        pass

class menu_gui_tests :
    'menu_gui'
    def __init__ ( self , test ) :
        self . _test = test
        self . _mediator = mediator_fake ( )
        self . _menu_gui = menu_gui ( self . _mediator )
        self . _mediator . _menu_gui = self . _menu_gui
    def test_show_menu_create_frame ( self ) :
        self . _mediator . _application_window = 'my app window'
        self . _menu_gui . show_menu ( )
        frame = self . _mediator . _frames [ 0 ]
        self . _test . assume_true ( frame . _packed )
        self . _test . assume_equal ( frame . _master , self . _mediator . _application_window )
    def test_show_menu_create_table_frame ( self ) :
        self . _menu_gui . show_menu ( )
        frame = self . _mediator . _frames [ 0 ]
        table_frame = self . _mediator . _frames [ 1 ]
        self . _test . assume_true ( table_frame . _packed )
        self . _test . assume_equal ( table_frame . _master , frame )
    def test_show_manu_create_new_table_in_frame ( self ) :
        self . _menu_gui . show_menu ( )
        table_frame = self . _mediator . _frames [ 1 ]
        self . _test . assume_equal ( self . _mediator . _create_new_table_in_frame_history , [ table_frame ] )    
    def test_hide_menu_destroy_frame ( self ) :
        self . _menu_gui . show_menu ( )
        frame = self . _mediator . _frames [ 0 ]
        self . _test . assume_false ( frame . _destroyed )
        self . _menu_gui . hide_menu ( )
        self . _test . assume_true ( frame . _destroyed )
